/*
 * @Author: Dorange.Wang
 * @Date: 2021-04-01 11:00:35
 * @LastEditors: your name
 * @LastEditTime: 2021-07-08 14:34:09
 * @Description: file content
 */
const devConfig = {
  httpProtocol: 'http://',
  wsProtocol: 'ws://',
  // hostname: '172.28.101.231',
  // hostname: '172.28.101.159',
  // port: '8089',
  hostname: 'hanma-lesscode.hc-iiot.com',
  port: '',
  prefix: '',
  wsPath: '',
  domainSuffix: 'lesscode'
}

const prodConfig = {
  httpProtocol: window.location.protocol + '//',
  wsProtocol: window.location.protocol === 'https:' ? 'wss://' : 'ws://',
  hostname: window.location.hostname,
  port: window.location.port,
  prefix: '',
  wsPath: '',
  domainSuffix: (window.location.host.match(/-([a-z]+)[.-]/) || [''])[1]
}

const apiConfig = process.env.NODE_ENV === 'production' ? prodConfig : devConfig
const { httpProtocol, hostname, port, prefix } = apiConfig

export default apiConfig
export const baseURL = `${httpProtocol}${hostname}${port ? ':' + port : ''}${prefix}`
